package com.cloud.bssp.netty.bytebuf;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;

/**
 * @description： TODO
 * @author：weirx
 * @date：2021/11/11 16:43
 * @version：3.0
 */
public class ReadTest {

    public static void main(String[] args) {
        //申请长度是10的buffer
        ByteBuf byteBuf = ByteBufAllocator.DEFAULT.buffer(10);

        //写入5个长度的字节数组
        byte[] bytes = new byte[]{1, 2, 3, 4, 5};
        byteBuf.writeBytes(bytes);
        System.out.println(byteBuf);

        //直接读取下一个字节
        System.out.println(byteBuf.readByte());
        System.out.println(byteBuf);

        System.out.println(byteBuf.readByte());
        System.out.println(byteBuf);

        //读取自己数组

        byteBuf.readBytes(new byte[3]);
        System.out.println(byteBuf);
    }
}
